/*
 * Copyright (c) 2009 John Pritchard, WTKX Project Group
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package wtkx.in;

import wtkx.Component;

/**
 * A repaint jump can provide three quick repaints or frames for
 * revalidating the scene graph or animation.  Not more than three
 * because the utility of the facility is reasonable only briefly.
 * Animating one component this way starves the remainder of the scene
 * graph from visual updates.  And validating for more time than the
 * 180 milliseconds provided is having a serious problem and this very
 * aggressive process needs to return control back to the application.
 * 
 * @author jdp
 */
public abstract class RepaintJump
    extends RuntimeException
{
    public final static class Animating
        extends RepaintJump
    {
        public final int x, y, w, h;
        public final long delay;
        public final boolean reset;

        public Animating(){
            this(30L,null,false);
        }
        public Animating(long delay){
            this(delay,null,false);
        }
        /**
         * @param delay Millis between twenty and one hundred.
         * @param c Subject 
         * @param override Starve the scene 
         */
        public Animating(long delay, Component c, boolean override){
            super();
            if (20 < delay && delay < 100){
                this.delay = delay;
                if (null != c){
                    this.x = c.getIntX();
                    this.y = c.getIntY();
                    this.w = c.getIntWidth();
                    this.h = c.getIntHeight();
                }
                else {
                    this.x = 0;
                    this.y = 0;
                    this.w = 0;
                    this.h = 0;
                }
                this.reset = override;
            }
            else
                throw new IllegalArgumentException(String.valueOf(delay));
        }
    }
    public final static class Validating
        extends RepaintJump
    {
        public Validating(){
            super();
        }
    }


    public RepaintJump(){
        super();
    }

}